Repository navigation
feat(contrib/aws/aws-sdk-go-v2): add SQS Data Streams consume checkpoints - #5902
robcarlan-datadog wants to merge 9 commits into
Conversation
…ints ReceiveMessage now sets a Data Streams consume checkpoint for each returned message, chained from the producer's pathway in the _datadog attribute (String or Binary), or from the SNS notification in the body when SNS raw message delivery is off. The new pathway is written back into the message's _datadog attribute so consumers can continue it. ReceiveMessage asks for _datadog unless All or .* is already requested. Data Streams follows the Kafka integrations: on with DD_DATA_STREAMS_ENABLED, or per client with the new WithDataStreams option. The produce checkpoint is gated on the same switch. Refs DSM2-676 Environment: Datadog workspace Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Config Audit |
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: dd3d968 | Docs | View more details | Give us feedback! |
|
@arp review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 18abf17f57
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
The most critical production concern is that WithDataStreams() does not wire into DSM processor activation, so all checkpoints silently no-op when DD_DATA_STREAMS_ENABLED is unset with the real tracer. A second distinct issue is that injecting the _datadog attribute on a fully-loaded 10-attribute SQS message exceeds SQS's attribute limit, causing downstream send operations to be rejected.
🤖 Bits Code Review · Commit 18abf17
…e, document WithDataStreams ReceiveMessage no longer adds _datadog to a message that already has the SQS maximum of 10 attributes, so forwarding those attributes still succeeds. The consume checkpoint is still set. The tracer creates its Data Streams processor only when DD_DATA_STREAMS_ENABLED is set, so WithDataStreams has no effect on its own, as in the Kafka integrations. The godoc now says so. Refs DSM2-676 Environment: Datadog workspace Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
More details
The PR adds AWS SDK v2 SQS consume checkpoints with producer/SNS pathway propagation. The update prevents eleventh-attribute insertion and corrects the WithDataStreams() contract to require DD_DATA_STREAMS_ENABLED=true at tracer startup; both earlier findings are resolved, with no open findings remaining.
🤖 Bits Code Review · Commit 5763506
The tracer starts its Data Streams processor only when DD_DATA_STREAMS_ENABLED is set, so the option had no effect on its own. SQS Data Streams Monitoring now follows that setting only. Making a per-integration option work needs a tracer change, tracked separately. Refs DSM2-676 Environment: Datadog workspace Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… limit traceBudget.inject refused to inject whenever a message had 10 attributes, even when one of them was _datadog and injection would only replace it. Since ReceiveMessage now requests and writes back _datadog, forwarding a received message with 9 user attributes sent the upstream producer's trace context and the consume-side pathway instead of the current span's. The limit now applies only when _datadog would be added. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
With DSM enabled, receiving a valid message at SQS’s 1 MiB limit adds a pathway attribute that makes it too large to forward. The existing send-side guard leaves those oversized received attributes intact.
🤖 Bits Code Review · Commit ec4aaa5
… checkpoints setConsumeCheckpoint wrote the _datadog attribute into received messages after only checking the attribute-count limit, so a message with a body near the 1 MiB payload limit grew past it when forwarded. Route the write through the same trace budget the send paths use, which skips the attribute when it would exceed the limit or when malformed UTF-8 would expand past it, while still recording the consume checkpoint. Environment: Datadog workspace Co-Authored-By: Claude Code <noreply@anthropic.com>
There was a problem hiding this comment.
The PR adds AWS SDK v2 SQS DSM produce and consume checkpoints under DD_DATA_STREAMS_ENABLED.
It propagates pathways through message attributes and SNS envelopes.
The new commit fixes the reported single-message byte-limit overflow.
One issue remains: receive-added attributes can overflow a forwarded batch’s aggregate 1 MiB budget.
The batch send path preserves those attributes, causing SQS rejection.
🤖 Bits Code Review · Commit bf8cd33
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
…eds the byte limit Forwarding received messages in one SendMessageBatch can push the batch past SQS's aggregate payload limit: each message passed the per-message budget at receive and gained _datadog, but their combined size exceeds the limit the batch path enforces across all entries. When the batch budget cannot absorb a write, remove the entry's stale _datadog instead of preserving it, so a batch the caller could have sent without the tracer still goes through. Covered by TestForwardDropsDatadogAtBatchByteLimit. Environment: Datadog workspace Co-Authored-By: Claude Code <noreply@anthropic.com>
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
There was a problem hiding this comment.
The two most critical issues are: (1) freed bytes from deleted _datadog attributes are never credited back to the shared batch byte budget, causing later entries to unnecessarily lose trace/DSM context in near-limit batches; and (2) the aggregate-budget setup and size-repair logic are incorrectly gated on canInject, so batches can still exceed SQS's 1 MiB limit when injection is disabled but DSM enrichment is active.
🤖 Bits Code Review · Commit 18ef0b4
… the enricher Stripping a stale _datadog from a batch entry freed its bytes but the aggregate budget never saw them, so later entries that would fit in that room needlessly lost their injection. Credit the removed attribute's size, and its UTF-8 expansion when it was already counted, back to the budget. The aggregate budget and the strip also ran only while trace injection was enabled, so with DSM on and injection disabled a forwarded batch of received near-limit messages could still exceed the aggregate limit; build the budget and strip independently of injection, dropping _datadog from entries while the batch is over the limit. Environment: Datadog workspace Co-Authored-By: Claude Code <noreply@anthropic.com>
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
There was a problem hiding this comment.
More details
The PR adds SQS consume checkpoints under DD_DATA_STREAMS_ENABLED, with the ineffective per-client option removed and attribute/byte-limit safeguards retained. Stripped metadata now replenishes the batch budget, preserving later context when it fits, and size repair runs with injection disabled; all reported findings are resolved.
🤖 Bits Code Review · Commit 3782227
kakkoyun
left a comment
There was a problem hiding this comment.
One change is needed before this can merge. See the inline comment.
|
|
||
| messageSize := sendMessageSize(params) | ||
| traceContext, err := getTraceContext(ctx, span, queueName(params.QueueUrl), messageSize) | ||
| traceContext, err := e.getTraceContext(ctx, span, queueName(params.QueueUrl), messageSize) |
There was a problem hiding this comment.
In handleSendMessage, remove an existing _datadog attribute when budget.inject returns nil, matching handleSendMessageBatch. When a forwarded message already holds a consume checkpoint and fills the byte budget, handleSendMessage now sends the stale _datadog attribute unchanged. Add a single-send test similar to TestForwardDropsDatadogAtBatchByteLimit.
There was a problem hiding this comment.
Addressed in a3682ad: handleSendMessage now strips an existing _datadog attribute when budget.inject returns nil, mirroring handleSendMessageBatch, and TestForwardDropsDatadogAtByteLimit covers the single-send case.
…d exceeds the byte limit handleSendMessage left an existing _datadog attribute in place when the trace budget could not fit the fresh context, forwarding the stale consume checkpoint instead of dropping it. Strip the attribute the way handleSendMessageBatch does, copying the attribute map so the caller's stays untouched. Environment: Datadog workspace Co-Authored-By: Claude Code <noreply@anthropic.com>
|
@DataDog review |
There was a problem hiding this comment.
A consumer that receives nine user attributes, adds another, and forwards the message can send eleven attributes after the new consume checkpoint is added. SQS rejects these otherwise valid messages.
🤖 Bits Code Review · Commit a3682ad
Co-authored-by: datadog-prod-us1-3[bot] <266080212+datadog-prod-us1-3[bot]@users.noreply.github.com>
|
@DataDog review |
There was a problem hiding this comment.
More details
No reportable defect was identified in the SQS checkpoint propagation paths. Focused execution remains unverified because the static reviewer’s dependency proxy was unreachable.
🤖 Bits Code Review · Commit dd3d968
What does this PR do?
Data Streams Monitoring for aws-sdk-go-v2 SQS, on both sides:
SendMessage,SendMessageBatch): sets adirection:out,type:sqs,topic:<queue>checkpoint per message and injects the pathway into the message's_datadogattribute. Main already did this whenever the tracer's DSM processor ran; it now followsDD_DATA_STREAMS_ENABLED.ReceiveMessage), new: asks SQS for the_datadogattribute (unlessAllor.*is already requested), sets onedirection:in,type:sqs,topic:<queue>checkpoint per message with the producer's pathway as parent, and writes the new pathway back into_datadog. It reads the pathway from a String or Binary_datadogattribute, or from the SNS notification in the body when SNS raw delivery is off.Both turn on with
DD_DATA_STREAMS_ENABLED=true. There's no new public option. A per-integrationWithDataStreams()would do nothing on its own, because the tracer starts its DSM processor only with the env var, so it's left to a follow-up. When a message already has the SQS maximum of 10 attributes, the pathway isn't written back, so forwarding those attributes still works.Motivation
Go SQS consumers were missing from DSM, so pathways broke at Go hops. Replaces #4788, rebased onto the
Enricherrefactor. Accepting the double-encoded .NET context is out of scope.Testing
Unit tests in
internal/sqsandawscover produce and consume through the middleware, String, Binary and SNS-envelope carriers, malformed input, and DSM off.go test -race ./...andgolangci-lintpass on the module.BenchmarkEnrichResponsemeasures the per-message decode. End to end against LocalStack and a real agent, a producer, a forwarder and a consumer linked produce → consume → produce → consume across two queues.Reviewers: apm-go for the receive-path decode, data-streams-monitoring for DSM behavior.
🤖 Generated with Claude Code